package org.delphy.indy2.containers.carbonTabDockClasses
{
	import flash.events.MouseEvent;
	
	import mx.controls.Button;
	import mx.styles.StyleManager;
	
	import org.delphy.indy2.core.ICarbonComponent;

	//--------------------------------------
	//  Styles
	//--------------------------------------
	
	/**
	 * Theme color
	 *
	 * @default 0x00B3E8
	 */
	[Style(name="textColor", type="Number", inherit="no")]
	
	public class CarbonTabWidget extends Button implements ICarbonComponent
	{		
		/**
		 * @public
		 * 
		 * @default 0x00B3E8
		 */
		protected var _textColor : Number;

		/**
		 * Constructor
		 */
		public function CarbonTabWidget()
		{
			super();
			toggle=true;
			
			addEventListener(MouseEvent.CLICK,onClick);
		}
		
		/**
		 * @protected
		 */
		override protected function commitProperties():void{
			super.commitProperties();
			
			if(!styleName)
				styleName="carbonTabWidget";
			
			if(!getStyle("textColor"))
				_textColor = StyleManager.getStyleDeclaration(".carbonTabWidget").getStyle("textColor");
			else
				_textColor=getStyle("textColor");
			
			styleChanged("textColor");
			
			if(selected){
				setStyle("color",_textColor);
			}
			else{
				setStyle("color",0xCCCCCC);
			}
			
		}
		
		/**
		 * @public
		 */
		override public function styleChanged(styleProp:String) : void{
			super.styleChanged(styleProp);
			
			if(styleProp=="textColor"){
				setStyle("indicatorColor",_textColor);
				setStyle("textRollOverColor",_textColor);
				setStyle("textSelectedColor",_textColor);					
			}
		}
		
		/**
		 * @protected
		 * Handler for MouseEvent.CLICK
		 */
		protected function onClick(evt:MouseEvent):void{
			if(selected){
				setStyle("color",_textColor);
			}
			else{
				setStyle("color",0xCCCCCC);
			}	
		}
		
		/**
		 * @public
		 */
		public function get defaultStyleName():String{
			return "carbonTabWidget";
		}
	}
}